package com.sample.rx3.libs.rxjava;

import android.content.Context;
import android.graphics.Bitmap;

import androidx.annotation.Nullable;

import com.loyal.client.impl.RxImpl;
import com.loyal.rx3.BaseRxSubscriber;
import com.loyal.rx3.RetroManager;

import io.reactivex.rxjava3.core.Observable;

public class RxJavaTaskSubscriber<T> extends BaseRxSubscriber<T> implements RxJavaTaskServer {

    @Override
    public void createServer(RetroManager manager) {
    }

    public RxJavaTaskSubscriber() {
        showProgressDialog(true);
    }

    @Override
    public RxImpl<T> withContext(@Nullable Context context) {
        return super.withContext(context);
    }

    @Override
    public Observable<String> saveBmp(final String savePath, final Bitmap bitmap) {
        return Observable.just(savePath).
                map(path -> {
                    Thread.sleep(2000L);
                    return "RxJava测试";
                });
    }

    @Override
    public Observable<String> saveByteArray(String savePath, final byte[] bytes) {
        return Observable.just(savePath).map(path -> /*ImageUtil.savePhoto(bytes, path)*/"");
    }
}

